﻿@{
    ViewData["Title"] = "Update";
    Layout = "~/Areas/Admin/Views/_Layout.cshtml";
    var Id = (ViewContext.HttpContext.Request.Query["Id"]).ToString();
}
<div style="margin-top:3em;margin-right:5em">
    <form class="layui-form" action="" id="formdata" lay-filter="formdata">
        <input hidden name="Id" value="@Id" />
        <div class="layui-form-item">
            <label class="layui-form-label">过滤IP</label>
            <div class="layui-input-block">
                <input type="text" name="startIP" required lay-verify="required|ip" placeholder="过滤IP" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开启过滤</label>
            <div class="layui-input-block">
                <input type="radio" name="isEnable" value="true" title="开启">
                <input type="radio" name="isEnable" value="false" title="关闭">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <textarea name="description" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" type="button"  lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>

<script>
//Demo
layui.use('form', function(){
  var form = layui.form;
    $.get("/admin/ipfilter/GetData", { Id:'@Id'}, function (repo)
    {
        $("#formdata").initForm(repo.data);
        form.render()
    });
  //监听提交
  form.on('submit(formDemo)', function(data){
          BaseAjax('post', "/admin/ipfilter/update", data.field, function (repo) {
              if (repo.status == ajaxStatus.OK)
                  x_admin_close();
          })
  });
});
</script>

